package com.zhx.basis;

import sun.misc.Unsafe;

public class 字符串常量池 {
    public static void main(String[] args) {

        String s1 = "a";
        String s2 ="b";
        String s3 = "a" + "b";
        String s4 = s1 + s2;
        String s5 = "ab";
        String s6 = s4.intern();


        System.out.println(s3 == s4);//false
        System.out.println(s3 == s5);//true
        System.out.println(s3 == s6);//true


        String x2 = new String("c") + new String("d");
        x2.intern();
        String x1 = "cd";
        //问，如果调换了【最后两行代码】的位置呢，如果是jdk1.6呢
        System.out.println(x1 == x2);//true

    }
}
